<?
#####################################################
#  COPYRIGHT NOTICE
#####################################################
# In the following statements, the term "this 
# program" refers to all files associated with the
# execution and distribution of Adtrackz.
#
# This Program is Copyright 2004 Jonah Klimack.
# All Rights Reserved. 
#
# Selling the code for this program, modifying 
# and/or redistributing the code for this program
# in part or in whole over the Internet or in any 
# other medium is expressly forbidden. Violators
# will be prosecuted to the fullest extent of the law
# Copyright and header information may not be
# modified.
#
# This program is distributed "as is" and without 
# warranty of any kind, either express or implied.
# In no event shall the liability of Jonah Klimack 
# for any damages, losses and/or causes of 
# action exceed the total amount paid by the 
# user for this software.		
#####################################################
# DO NOT MODIFY ANYTHING IN THIS FILE
#####################################################

require "config.php";

$campaign = mysql_fetch_row(mysql_query("select * from adtrackz_campaigns where ID='$cID'"));
$months = array(1 => 'January', 'February','March','April','May','June','July','August','September','October','November','December');

//get this month
$days_in_month = date("t");
$from_timestamp = mktime (0,0,0,date("m"),01,date("Y")); 
$to_timestamp = mktime (23,59,59,date("m"),$days_in_month,date("Y")); 
$month = date("m");
$year = date("Y");
$trim_month = trim(intval($month));

//need to build an array of days and the # of hits for each day for this month
$clickdata = mysql_query("select timest from adtrackz_clicks where campaignID='$cID' && subID='$sID' && timest >= '$from_timestamp' && timest <= '$to_timestamp'");
$uclickdata = mysql_query("select timest from adtrackz_clicks where campaignID='$cID' && subID='$sID' && timest >= '$from_timestamp' && timest <= '$to_timestamp' && uniqueflag=1");

while ($click = mysql_fetch_row($clickdata))
{
	if (date("n",$click[0]) == $trim_month) //if this click was during selected month
	{
		// +1 for clicks for this day in this month
		$day_of_month = date("j", $click[0]); 
		$dc[$day_of_month] += 1;
	}
}
if (!$dc)
	$dc = array_fill (1,30,0);
else
	ksort($dc);
while ($uclick = mysql_fetch_row($uclickdata))
{
	if (date("n",$uclick[0]) == $trim_month) //if this click was during selected month
	{
		// +1 for clicks for this day in this month
		$day_of_month = date("j", $uclick[0]); 
		$udc[$day_of_month] += 1;
	}
}
if (!$udc)
	$udc = array_fill (1,30,0);
else
	ksort($udc);



//label for graph
$month_label = "Daily Clicks ".$months[$trim_month].", ".$year;

include 'charts.php';

$chart[ 'chart_data' ] = array ( array ("","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31" ), array ( "Unique Clicks",$udc[1],$udc[2],$udc[3],$udc[4],$udc[5],$udc[6],$udc[7],$udc[8],$udc[9],$udc[10],$udc[11],$udc[12],$udc[13],$udc[14],$udc[15],$udc[16],$udc[17],$udc[18],$udc[19],$udc[20],$udc[21],$udc[22],$udc[23],$udc[24],$udc[25],$udc[26],$udc[27],$udc[28],$udc[29],$udc[30],$udc[31]),array ( "Raw Clicks",$dc[1],$dc[2],$dc[3],$dc[4],$dc[5],$dc[6],$dc[7],$dc[8],$dc[9],$dc[10],$dc[11],$dc[12],$dc[13],$dc[14],$dc[15],$dc[16],$dc[17],$dc[18],$dc[19],$dc[20],$dc[21],$dc[22],$dc[23],$dc[24],$dc[25],$dc[26],$dc[27],$dc[28],$dc[29],$dc[30],$dc[31]) );

$chart[ 'axis_category' ] = array ( 'font'=>"arial", 'bold'=>true, 'size'=>12, 'color'=>"000022", 'alpha'=>75, 'skip'=>2 ); 
$chart[ 'axis_value' ] = array ( 'font'=>"arial", 'bold'=>true, 'size'=>10, 'color'=>"000022", 'alpha'=>75, 'steps'=>4, 'prefix'=>"", 'suffix'=>"", 'decimals'=>0, 'separator'=>"", 'show_min'=>false );

$chart[ 'chart_bg' ] = array ( 'positive_color'=>"448800", 'negative_color'=>"ffeeAA", 'positive_alpha'=>20, 'negative_alpha'=>100 );
$chart[ 'chart_border' ] = array ( 'color'=>"000000", 'top_thickness'=>1, 'bottom_thickness'=>1, 'left_thickness'=>1, 'right_thickness'=>1 );
$chart[ 'chart_rect' ] = array ( 'x'=>60, 'y'=>50, 'width'=>400, 'height'=>200 );
//$chart[ 'chart_type' ] = "stacked column"; 
$chart[ 'chart_type' ] = "column"; 
//$chart[ 'chart_type' ] = "Line";

$chart[ 'draw_text' ] = array (	
						array ( 'color'=>"663333", 'alpha'=>75, 'font'=>"arial", 'rotation'=>0, 'bold'=>true, 'size'=>14, 'x'=>60, 'y'=>50, 'width'=>300, 'height'=>300, 'text'=>$month_label, 'h_align'=>"right", 'v_align'=>"top" ) );

$chart[ 'legend_rect' ] = array ( 'x'=>-100, 'y'=>-100, 'width'=>10, 'height'=>10, 'margin'=>0 ); 

$chart[ 'series_color' ] = array ( "FFFFFF", "FA7F14" );
$chart[ 'series_gap' ] = array ( 'set_gap'=>0, 'bar_gap'=>0 );

$chart[ 'legend_bg' ] = array ( 'bg_color'=>"ffffff", 'bg_alpha'=>35, 'border_color'=>"000000", 'border_alpha'=>0, 'border_thickness'=>0 ); 
$chart[ 'legend_label' ] = array ( 'layout'=>"horizontal", 'font'=>"arial", 'bold'=>true, 'size'=>13, 'color'=>"444466", 'alpha'=>90 ); 
$chart[ 'legend_rect' ] = array ( 'x'=>125, 'y'=>10, 'width'=>250, 'height'=>10, 'margin'=>5 ); 

SendChartData ( $chart );


?>
